package cl.whyem.spring.integration.mail.service.impl;

import cl.whyem.spring.integration.mail.service.DesuscripcionMailService;
import cl.transbank.ahorro.persistencia.dao.EmisorDAO;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

//@Scope("prototype")
@Service("desuscripcionMailService")
public class DesuscripcionMailServiceImpl implements DesuscripcionMailService {

    private final static Logger logger = LoggerFactory.getLogger(DesuscripcionMailServiceImpl.class);

    @Override
    public void handleMails(MimeMessage mimeMessage) {
        try {
            logger.debug("Mensaje asunto : {}", mimeMessage.getSubject());
            logger.debug("Mensaje flags : {}", ToStringBuilder.reflectionToString(mimeMessage.getFlags(), ToStringStyle.SHORT_PREFIX_STYLE));
        } catch (MessagingException ex) {
            logger.error("Error: {}", ex.getMessage(), ex);
        }
    }

}
